import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2024-02-14
 * Time: 8:29
 */
public class Test {
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int  i = 0; i < pushV.length; i++){
            stack.push(pushV[i]);
            while(!stack.isEmpty() && j < popV.length && stack.peek() == popV[j]){
                stack.pop();
                j++;
            }
        }

        return j >= popV.length;

    }
    public static void main(String[] args) {

    }
}
